package ds.factcom.controller.client;

import java.util.List;
import java.util.Observer;

import ds.factcom.domain.client.Client;
import ds.factcom.exception.ClientHasInvoicesException;
import ds.factcom.exception.ExistDomainException;
import ds.factcom.exception.NotExistDomainException;
import ds.factcom.model.ClientModel;

/**
 * 
 * @author Javier De Luca, Maximiliano Herrera, Matias Samblancat
 *
 */
public class ClientController  implements IClientController {

	private final ClientModel clientModel;
	
	public ClientController(ClientModel clientModel){
		this.clientModel = clientModel;
	}

	public List<String> findClientDebtor() {
		return this.clientModel.findClientDebtor();
	}

	public void addObserver(Observer observer) {
		this.clientModel.addObserver(observer);
	}
	
	public void findByDocument(String documentType, String documentNumber) throws NotExistDomainException {
		this.clientModel.findByDocument(documentType, documentNumber);
	}
	

	public void insert(String name, String documentType, String documentNumber,
			String address) throws ExistDomainException {

			this.clientModel.insert(name,documentType, documentNumber, address);
	}

	public void delete(String documentType, String documentNumber) throws NotExistDomainException, ClientHasInvoicesException {

			this.clientModel.delete(documentType, documentNumber);
	}
	
	public void modify(String name,  String address) throws NotExistDomainException{
		
			this.clientModel.modify(name,address);
	}
	
	public String getAddress(){
		return this.clientModel.getClient().getAddress();
	}
	
	public String getDocumentNumber(){
		return this.clientModel.getClient().getDocument().getNumber();
	}
	
	public String getDocumentType(){
		return this.clientModel.getClient().getDocument().getDocumentType().getValue();
	}
	
	public String getName(){
		return this.clientModel.getClient().getName();
	}
	
	public int getId(){
		return this.clientModel.getClient().getId();
	}
	
	public Client getClient() {
		return this.clientModel.getClient();
	}
	
	public void setClient(Client client) {
		this.clientModel.setClient(client);
	}
}
